/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年9月3日
 */
package com.massyframework.beanskin.service;

import java.util.Map;

/**
 * 提供服务注册的方法
 * 
 * <p>
 * 服务注册时，可以注册一个伴生的属性，根据属性可以进行服务过滤
 */
public interface ServiceRegistry {

	/**
     * 使用<code>service</code>实例注册服务
     * @param exportType {@link Class}, 服务类型
     * @param service {@link S}, 服务实例
     * @param props {@link Map}, 服务属性，可以为null.
     * @param <S>
     * @return {@link ServiceRegistration}
     */
    <S> ServiceRegistration<S> register(Class<S> exportType, S service, Map<String, Object> props);

    /**
     * 使用<code>service</code>实例注册服务
     * @param exportTypes {@link Class}数组, 服务类型
     * @param service {@link Object}, 服务实例
     * @param props {@link Map}, 服务属性，可以为null.
     * @return {@link ServiceRegistration}
     */
    ServiceRegistration<?> register(Class<?>[] exportTypes, Object service, Map<String, Object> props);

    /**
     * 使用<code>factory</code>实例注册服务
     * @param exportType {@link Class}, 服务类型
     * @param factory {@link ServiceFactory}, 服务工厂
     * @param props {@link Map}, 服务属性，可以为null.
     * @param <S>
     * @return {@link ServiceRegistration}
     */
    <S> ServiceRegistration<S> register(Class<S> exportType, ServiceFactory<S> factory, Map<String, Object> props);

    /**
     * 使用<code>factory</code>实例注册服务
     * @param exportTypes {@link Class}数组, 服务类型
     * @param factory {@link ServiceFactory}, 服务工厂
     * @param props {@link Map}, 服务属性，可以为null.
     * @return {@link ServiceRegistration}
     */
    ServiceRegistration<?> register(Class<?>[] exportTypes, ServiceFactory<?> factory, Map<String, Object> props);
}
